//
//  AroundViewController.m
//  YouthOlympic2014
//
//  Created by xiangpaopao on 14-6-30.
//  Copyright (c) 2014年 mitian. All rights reserved.
//

#import "AroundViewController.h"
#import "WebShowViewController.h"
#import "InsideMapViewController.h"
#import "ShowVenuesViewController.h"
#import "UIViewController+MMDrawerController.h"
#import "HCViewController.h"

@interface AroundViewController ()

@property (nonatomic, strong)NSArray *titleArr;
@property (nonatomic, strong)UIViewController *leftCtrl;
@property (nonatomic, strong)UIViewController *rightCtrl;

@end

@implementation AroundViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setTitle:@"青奥村周边"];
    _titleArr = [NSArray arrayWithObjects:@"青奥村地图",@"青奥村3D地图",@"餐厅服务",@"宗教服务",@"健身训练服务",@"青奥村广场",@"交通服务",@"青奥小贴士", nil];
    
    self.leftCtrl = self.mm_drawerController.leftDrawerViewController;
    self.rightCtrl = self.mm_drawerController.rightDrawerViewController;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.mm_drawerController.leftDrawerViewController = self.leftCtrl;
    self.mm_drawerController.rightDrawerViewController = self.rightCtrl;
    
}

#pragma mark - TableView delegate & datasource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section {
    return [_titleArr count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"aroundCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    if (cell == nil) {
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil];
        cell = [topLevelObjects objectAtIndex:0];
    }
    [cell.textLabel setText:[_titleArr objectAtIndex:indexPath.row]];
    
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{


    
    if (indexPath.row == 0) {
        InsideMapViewController *mapCtrl = [[InsideMapViewController alloc] init];
        [self.navigationController pushViewController:mapCtrl animated:YES];
        
    }else if (indexPath.row == 1) {
        self.mm_drawerController.leftDrawerViewController = nil;
        self.mm_drawerController.rightDrawerViewController = nil;
        
        ShowVenuesViewController *ctl = [[ShowVenuesViewController alloc] init];
        ctl.SceneNo = @"AYV2";
        ctl.title = @"青奥村3D地图";
        
        [self.navigationController pushViewController:ctl animated:YES];
    }else if (indexPath.row == 7) {
        
        HCViewController *ctl = [[HCViewController alloc] init];
        
        [self.navigationController pushViewController:ctl animated:YES];
    }else{
        WebShowViewController *webCtrl = [self.storyboard instantiateViewControllerWithIdentifier:@"webShowCtrl"];
        webCtrl.webStr = [NSString stringWithFormat:@"http://res.airad.com/Olympic2014/service_%ld.html",(long)(indexPath.row -1)];
        
        [self.navigationController pushViewController:webCtrl animated:YES];
    }
        
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
}


@end
